feat: plugin support#5650
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## next #5650 +/- ##
==========================================
- Coverage 88.93% 81.97% -6.96%
==========================================
Files 13 13
Lines 5919 6037 +118
==========================================
- Hits 5264 4949 -315
- Misses 655 1088 +433 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
We should start it in webpack-dev-middleware, currently |
0d79407 to
8664549
Compare
d8084a7 to
9890a76
Compare
9890a76 to
616b803
Compare
bjohansebas
left a comment
There was a problem hiding this comment.
These changes should work without requiring any changes to webpack-cli yet. Once this is merged, we can work on a patch for webpack-cli to use the plugin support, but it is independent of changes to webpack-cli.
|
cc: @alexander-akait friendly ping for feedback |
|
Will look soon, I little bit busy, we should make the new major release the next week, I will help you to finish remains tasks |
|
@bjohansebas let's rebase |
1060a9c to
4591762
Compare
|
@bjohansebas can take a look at our failed tests, a lot of PRs without green, we need to resolve it, thanks |
bb3626c to
9912722
Compare
Those are just flaky tests, like before. You just need to rerun them and that's it. |
|
Looks like problem with lint here |
0102816 to
2d6d746
Compare
| // the user is not in control of the plugin lifecycle here, so we stay | ||
| // silent rather than logging a warning. | ||
| const isBuildMode = () => | ||
| childCompilers.every((child) => !child.watching && !child.options.watch); |
There was a problem hiding this comment.
Each compiler have watching when it is watching, no need to check on watch, at least I can see situation when watch will be true, but watching undefined
| if (seenFirstDone.has(childCompiler)) return; | ||
| seenFirstDone.add(childCompiler); | ||
| firstDoneCount++; | ||
| if (firstDoneCount < childCompilers.length) return; |
There was a problem hiding this comment.
Can you clarify when we need firstDoneCount?
| childCompiler.hooks.done.tapPromise(pluginName, () => | ||
| onChildDone(childCompiler), | ||
| ); | ||
| childCompiler.hooks.shutdown.tapPromise(pluginName, onChildShutdown); |
There was a problem hiding this comment.
Ideally we should have the same hooks for multi compiler, and so don't use for/of, but we can postpone it and improve later
| }; | ||
|
|
||
| for (const childCompiler of childCompilers) { | ||
| childCompiler.hooks.beforeCompile.tapPromise(pluginName, ensureSetup); |
There was a problem hiding this comment.
Can we avoid beforeCompile at all, it is unsafe in some cases, ideally we should use only done and shutdown
There was a problem hiding this comment.
I think we can done everything on done, also please add a test case what we really change outputFileSystem and use it, not webpack built-in the real fs
There was a problem hiding this comment.
Doing it only through done is complicated because there are processes that need to be initialized much earlier. That's why beforeCompile is used.
|
okay tomorrow i will continue with this |
c2dd24b to
4810909
Compare
b2914df to
5be7251
Compare
🦋 Changeset detectedLatest commit: 6efe969 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Allow webpack-dev-server to run as a webpack plugin. The server can now be created without explicitly passing a compiler, integrates with the compiler lifecycle to prevent multiple starts on recompilation, ensures clean shutdown, and supports MultiCompiler setups with multiple independent plugin servers.
Add e2e coverage for the plugin API (api-plugin.test.js), MultiCompiler and multiple independent plugin servers, build-mode behavior, and related logging snapshots. Add the compile helper and port mappings used by these tests.
Add a runnable example (app, webpack config and README) showing how to configure and use webpack-dev-server as a webpack plugin.
5be7251 to
07b85dc
Compare
|
Summary
What kind of change does this PR introduce?
Did you add tests for your changes?
Does this PR introduce a breaking change?
If relevant, what needs to be documented once your changes are merged or what have you already documented?